import java.util.HashSet;
import java.util.Scanner;

public class Set {
    public static int numJewelsInStones(String jewels, String stones) {
        HashSet<Character> set = new HashSet<>();
        for(int i=0;i<jewels.length();i++){
            char ch = jewels.charAt(i);
            set.add(ch);
        }
        int count=0;
        for(int i = 0;i<stones.length();i++){

            if(set.contains(stones.charAt(i))){
                count++;
            }
        }
        return count;
    }


    public static void main(String[] args) {
        //宝石与石头
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入宝石:");
        String jewels = sc.nextLine();//宝石
        System.out.println("请输入宝石和石头的混合:");
        String stones = sc.nextLine();//宝石加石头的混合
        int ret=numJewelsInStones(jewels, stones);//传入宝石和石头，输出宝石数量
        System.out.println("宝石的数量:"+ret);
    }
}
